package com.ckv.qcm.model;

import java.util.ArrayList;

import com.ckv.qcm.model.dao.ThemeDAO;

public class Theme {

	private long id;
	private String name;

	private static ThemeDAO dao = new ThemeDAO();

	public Theme() {
		super();
	}

	public Theme(long id, String name) {
		super();
		this.id = id;
		this.name = name;
	}

	public static ArrayList<Theme> findAll() {
		return dao.findAll();
	}

	public static Theme find(long id) {
		return dao.find(id);
	}

	public Theme create() {
		return dao.create(this);
	}

	public Theme update() {
		return dao.update(this);
	}

	public boolean delete() {
		return dao.delete(this);
	}

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Override
	public boolean equals(Object obj) {
		if (obj instanceof Theme)
			return this.id == ((Theme) obj).id;
		return false;
	}

	@Override
	public String toString() {
		return getName();
	}

}
